package com.tz.actions;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.tz.service.AccountService;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

import java.util.Map;

/**
 * Created by Administrator on 16-10-12.
 * URL : ~/account/transfer.action
 */
@Namespace("/account")
@Result(location = "/WEB-INF/jsp/transfer-result.jsp")
public class TransferAction extends ActionSupport {

    //B==>C
    private int from;
    private int to;
    private double amount;

    //C==>V
    private String result;

    @Autowired
    private AccountService accountService;

    public TransferAction() {
        System.out.println("TransferAction空参构造...");
    }

    @Action("transfer")
    public String transfer() {
        result = accountService.transfer(from, to, amount);
        return SUCCESS;
    }

    public int getFrom() {
        return from;
    }

    public void setFrom(int from) {
        this.from = from;
    }

    public int getTo() {
        return to;
    }

    public void setTo(int to) {
        this.to = to;
    }

    public double getAmount() {
        return amount;
    }

    public void setAmount(double amount) {
        this.amount = amount;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }
}
